package com.br.negocio.vo;

import java.io.Serializable;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

@Entity
@Table(name = "servicoVenda")
@NamedQueries ({
        @NamedQuery(name = "loadAllServicoVenda", query = "from ServicoVendaVO as pc where pc.vendaVO.codigo = :codigo"),
})
public class ServicoVendaVO implements Serializable {

        private static final long serialVersionUID = 1L;

        @EmbeddedId  
        private ServicoVendaPK servicoVendaPK;
        
        @Column(name = "custo_venda")
        private float custoVenda;
        
        @Column(name = "quantidade_vendida")
        private float quantidadeVendida;
        
        @JoinColumn(name="cod_venda", 
                        referencedColumnName="cod_venda",
                        nullable = false,
                        insertable=false, updatable=false)
        @ManyToOne(optional=false, fetch= FetchType.LAZY)
        @Basic(optional=false)
        @Fetch(FetchMode.JOIN)
        private VendaVO vendaVO;
        
        @JoinColumn(name="cod_servico", 
                        referencedColumnName="cod_servico",
                        nullable = false,
                        insertable=false, updatable=false)
        @ManyToOne(optional=false, fetch= FetchType.LAZY)
        @Basic(optional=false)
        @Fetch(FetchMode.JOIN)
        private ServicoVO servicoVO;
                
        public ServicoVendaVO(){
                servicoVendaPK = new ServicoVendaPK();
                servicoVO = new ServicoVO();
        }
        
        public ServicoVendaPK getServicoVendaPK() {
                return servicoVendaPK;
        }

        public void setServicoVendaPK(ServicoVendaPK servicoVendaPK) {
                this.servicoVendaPK = servicoVendaPK;
        }

        public float getQuantidadeVendida() {
                return quantidadeVendida;
        }

        public void setQuantidadeVendida(float quantidadeVendida) {
                this.quantidadeVendida = quantidadeVendida;
        }

        public VendaVO getVendaVO() {
                return vendaVO;
        }

        public void setVendaVO(VendaVO vendaVO) {
                this.vendaVO = vendaVO;
        }

        public ServicoVO getServicoVO() {
                return servicoVO;
        }

        public void setServicoVO(ServicoVO servicoVO) {
                this.servicoVO = servicoVO;
        }

        public float getCustoVenda() {
                return custoVenda;
        }

        public void setCustoVenda(float custoVenda) {
                this.custoVenda = custoVenda;
        }
}
